package server

import (
	"gc-rds-ha/internal/common"
	msg "gc-rds-ha/scripts"
	"log"

	"google.golang.org/protobuf/types/known/timestamppb"
)

type GcRdsHaServer struct {
	msg.GcRdsHaServer
	StartedTS *timestamppb.Timestamp

	RpcServer   *RPCServer
	serverStart chan struct{}
}

func NewDispatcherServer() *GcRdsHaServer {
	var options = []SetOption{
		WithName("gcrdsha"),
		WithPort(common.AgentConfig.Rpc.Port),
		WithListen(common.AgentConfig.Rpc.Listen),
	}
	rpcServer, err := NewRPCServer(options...)
	if err != nil {
		log.Fatal(err)
	}
	return &GcRdsHaServer{
		StartedTS:   timestamppb.Now(),
		RpcServer:   rpcServer,
		serverStart: make(chan struct{}),
	}
}
